const { createHmac } = require('crypto')
module.exports = class extends think.Service {
  model = this.model('user')
  // 添加用户
  addUser(ctx) {
    console.log('ssssssss',ctx.post())
    return 'aaa'
    // return this.model.add()
  }
  // 添加超级管理员
  async createSuperAdmin() {
    const val = {
      username: 'admin',
      password: createHmac('sha256', 'admin').digest('hex'),
      'role_id': 1
    }
    return this.model.createSuperAdmin(val)
  }
  // 查询用户
  async checkUser(ctx) {
    const val = {
      username: ctx.post('username'),
      password: createHmac('sha256', ctx.post('password')).digest('hex')
    }
    return this.model.checkUser(val)
  }
};
